<div ng-controller="communityRewardRuleCtrl">
    <div class="form-group">
        <label class="control-label" for="textinput">小区:</label>
        <input list="community_data_list" type="text" class="" ng-model="filter"/>
        <datalist id="community_data_list">
            <option value="all"></option>
            <option ng-repeat="comm in commList" value="{{comm.communityName}}"></option>
        </datalist>

        <button type="button" class="btn-primary btn-sm  " ng-click="findCommunities(filter)">搜索</button>
    </div>

    <button type="button" class="btn-primary btn-sm " ng-click="newDialog()">添加新奖励机制</button>
    <button type="button" class="btn-primary btn-sm " ng-click="editTimeDialog()">编辑活动日期</button>
    <button type="button" class="btn-primary btn-sm " ng-click="deleteRule()">批量删除</button>
    <div class="tab-content">
        <label>
            <input style="zoom:1.8;vertical-align:middle" ng-model="ck"
                   type="checkbox" ng-click="allCheck(ck,openType)"/>全选
        </label>
        <div class="tab-pane active" id="tab_a">
            <table class="table table-condensed">
                <thead>
                <tr>
                    <th>选择</th>
                    <th>小区名称</th>
                    <th>奖励原因</th>
                    <th>奖励类型</th>
                    <th>金额/量</th>
                    <th>代金券有限期</th>
                    <th>活动开始时间</th>
                    <th>活动结束时间</th>
                </tr>
                </thead>
                <tbody>
                <tr ng-repeat="rule in rule_list">
                    <td width="20"><input type="checkbox" style="zoom:1.3;" name="chkItem" ng-model="rulecheck" ng-click="ruleToggle(rule)" ng-change="checkChange(chc)"/> </td>
                    <th>{{rule.community_name}}<span ng-show="false">{{rule.community_id}}</span></th>
                    <th><span ng-show="rule.reward_source == 1">v认证</span><span
                            ng-show="rule.reward_source == 2">推荐用户</span></th>
                    <th><span ng-show="rule.type == 1">代金券</span><span ng-show="rule.type == 2">情值</span></th>
                    <th>{{rule.voucher_name }}</th>
                    <th>{{rule.reward_expiredate_length}}天</th>
                    <th>{{rule.from_time}}</th>
                    <th>{{rule.to_time}}</th>
                    <th>
                        <a class="btn btn-primary btn-xs" ng-click="updateDialog(rule)">编辑</a>
                        <a class="btn btn-danger btn-xs" ng-click="deleteDialog(rule)">删除</a>
                    </th>
                </tr>
                </tbody>
            </table>
        </div>
    </div>


    <div class="modal fade" id="setRuleTime_model" tabindex="-1" role="dialog" aria-labelledby="helpModalLabel"
         aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <!--<div class="modal-header">-->
                    <!--<button type="button" class="close" data-dismiss="modal"><span-->
                            <!--aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>-->
                    <!--<h5 class="modal-title" id="myModalLabel">{{popupTitle}}</h5>-->
                <!--</div>-->
                <div class="modal-body">
                    <p class="text-danger" ng-show="showErrorMsg">{{onErrorMsg}}</p>

                    <form class="form-horizontal" name="crule">

                        <div class="form-group">
                            <label for="5" class="control-label col-xs-2">活动开始时间</label>

                            <div class="col-xs-3">
                                <input type="text" id="startDate2" data-provide="datepicker"
                                       class="form-control datepicker" data-date-format="yyyy-mm-dd"
                                       ng-model="fromtime" required>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="6" class="control-label col-xs-2">活动结束时间</label>

                            <div class="col-xs-3">
                                <input type="text" id="endDate2" data-provide="datepicker"
                                       class="form-control datepicker" data-date-format="yyyy-mm-dd"
                                       ng-model="totime" required>
                            </div>
                        </div>

                    </form>

                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                    <button id="savebtn" type="submit" class="btn btn-default"
                            ng-click="saveTime()">保存
                    </button>
                </div>

            </div>
        </div>
    </div>

    <div class="modal fade" id="community_model" tabindex="-1" role="dialog" aria-labelledby="helpModalLabel"
         aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal"><span
                            aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                    <h5 class="modal-title" id="myModalLabel">{{popupTitle}}</h5>
                </div>
                <div class="modal-body">
                    <p class="text-danger" ng-show="showErrorMsg">{{onErrorMsg}}</p>

                    <form class="form-horizontal" name="crule">

                        <div class="form-group">
                            <label for="5" class="control-label col-xs-2">活动开始时间</label>

                            <div class="col-xs-3">
                                <input type="text" id="startDate" data-provide="datepicker"
                                       class="form-control datepicker" data-date-format="yyyy-mm-dd"
                                       ng-model="crule.from_time" required>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="6" class="control-label col-xs-2">活动结束时间</label>

                            <div class="col-xs-3">
                                <input type="text" id="endDate" data-provide="datepicker"
                                       class="form-control datepicker" data-date-format="yyyy-mm-dd"
                                       ng-model="crule.to_time" required>
                            </div>
                        </div>

                        <div class="form-group" ng-show = "!comChange">
                            <label for="1" class="control-label col-xs-2">小区名称</label>

                            <div class="col-xs-3">
                                <!--input type="text"  class="form-control"  ng-model="crule.communityName" placeholder="communityName" required -->
                                <select id="community_menu" class="form-control" ng-model="crule.community_id"
                                        ng-change="setCommunityName()" required>
                                    <option ng-repeat="comm in commList" value="{{comm.objId}}">{{comm.communityName}}
                                    </option>
                                </select>
                                <input ng-show="false" model="crule.community_name"/>
                            </div>
                        </div>
                        <div class="form-group" ng-show = "comChange">
                            <label for="1" class="control-label col-xs-2">小区名称</label><br><br>
                            <div style="width:500px;margin-left: 180px;" class = "communitys-select">
                                <input type="text" ng-model="cname" class="form-control" id = "cname_filter" ng-change="cnameFilter(cname)" placeholder="搜索小区" style = "width: 200px;">
                                <table id="manyCommunity" style="width:500px;" border="0" style="width: 100%;">
                                    <tr align="center">
                                        <td width = "200">
                                            <select id="communitys" multiple="multiple" ng-model="oneCommunity"
                                                    style="width: 200px;height:300px;">
                                                <option ng-repeat="comm in commList" value="{{comm.objId}}">{{comm.communityName}}</option>
                                            </select>
                                            <!--| filter:cname-->
                                        </td>
                                        <td width = "100">
                                            <input type="button" value=">>" id="addAllCommunity" ng-click="addAllCommunity()" /><br /><br />
                                            <input type="button" value=">" id="addCommunity" ng-click="addCommunity()" /><br /><br />
                                            <input type="button" value="<" id="removeCommunity" ng-click="removeCommunity()"/><br /><br />
                                            <input type="button" value="<<" id="removeAllCommunity" ng-click="removeAllCommunity()"/>
                                        </td>
                                        <td>
                                            <select id="selCommunitys" multiple="multiple"
                                                    style="width: 200px;height:300px;" ng-model="crule.community_id">
                                            </select>
                                        </td>

                                    </tr>
                                </table>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="2" class="control-label col-xs-2">奖励原因</label>

                            <div class="col-xs-3">
                                <select class="form-control" ng-model="crule.reward_source" required>
                                    <option ng-repeat="source in  reward_sources" value="{{source.value}}">
                                        {{source.name}}
                                    </option>
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="3" class="control-label col-xs-2">奖励类型</label>

                            <div class="col-xs-3">
                                <select class="form-control" ng-model="crule.voucher_type_id"
                                        ng-change="changeVoucherType(crule.voucher_type_id)" required>
                                    <option ng-repeat="type in  typeList" value="{{type.id}}">{{type.voucher_name}}
                                    </option>
                                </select>
                            </div>
                        </div>
                        <div ng-show="is_voucher_type ===1" class="form-group">
                            <label for="4" class="control-label col-xs-2">代金券有效期</label>

                            <div class="col-xs-3">
                                <input type="text" class="form-control" ng-model="crule.reward_expiredate_length"
                                       required>
                            </div>
                            <p class="col-xs-4" style="padding-top: 0.5em">天</p>
                        </div>
                    </form>

                </div>
                <div class="modal-footer">
                    <button id="saveButton" type="submit" ng-show="addBtnShow" class="btn btn-default"
                            ng-click="add(crule)">保存
                    </button>
                    <button id="updateButton" type="submit" ng-show="updateBtnShow" class="btn btn-default"
                            ng-click="update(crule)">修改
                    </button>
                    <button id="deleteButton" type="submit" ng-show="deleteBtnShow" class="btn btn-default"
                            ng-click="delete(crule)">删除
                    </button>
                    <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                </div>

            </div>
        </div>
    </div>

</div>

